﻿using AbpApplication.InPut;
using CommunityToolkit.Mvvm.Input;
using NewWms.Apiservice;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using Reconstruct_Desktop.Apiservice.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Reconstruct_Desktop.ViewModels.DialogsModel
{
    public class UpdateWarehouselineBoxTypeDialogViewModel : BindableBase, IDialogAware
    {


        public UpdateWarehouselineBoxTypeDialogViewModel()
        {
            BoxTypeDtos=new List<BoxTypeDto>();
            baseService = new BaseService();
            InPut_BaseService23=new InPut_BaseService23();
            Command = new DelegateCommand<string>(Method);
            Getlist_Bintypes();
        }
        public DelegateCommand<string> Command { get; set; }
        private IBaseService baseService;
        private List<BoxTypeDto> boxTypeDtos;
        public List<BoxTypeDto> BoxTypeDtos
        {
            get { return boxTypeDtos; }
            set { boxTypeDtos = value; RaisePropertyChanged(); }
        }


        private InPut_BaseService23 inPut_BaseService23;

        public InPut_BaseService23 InPut_BaseService23
        {
            get { return inPut_BaseService23; }
            set { inPut_BaseService23 = value; RaisePropertyChanged(); }
        }


        private async void Getlist_Bintypes()
        {
            BoxTypeDtos = await baseService.Getlist_Bintypes();
        }

      
        public async void Method(string obj)
        {
            switch (obj)
            {
                case "CloseDialog": RequestClose?.Invoke(null); break;
                case "UpdateWarehouselineBoxType": UpdateWarehouselineBoxType(); break;
          
            }
        }

        public void UpdateWarehouselineBoxType()
        {
            baseService.UpdateWarehouselineBoxType(InPut_BaseService23);

        }









        public string Title { get; set; } = "更改属性";

        public event Action<IDialogResult> RequestClose;

        public bool CanCloseDialog()
        {
            return true;
        }

        public void OnDialogClosed()
        {
           
        }

        public void OnDialogOpened(IDialogParameters parameters)
        {
            foreach (var key in parameters.Keys)
            {
                var value = parameters.GetValue<object>(key);
                InPut_BaseService23.Id_WarehouseLines.Add(Guid.Parse(value.ToString()));
            }
        }
    }
}
